package com.bolt.admin.module.log.service;

import com.bolt.admin.module.log.entity.LogEntity;
import com.bolt.admin.module.log.repository.LogRepository;
import com.bolt.support.base.service.BaseService;
import com.bolt.support.spring.jpa.jpql.Clauses;
import com.bolt.support.spring.jpa.repository.BasicJpaRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Auto Generate Javadoc
 *
 * @author 日期:2020-10-16 10:59:58
 *         系统日志
 **/
@Service
@Transactional(readOnly = true, rollbackFor = Exception.class)
public class LogService extends BaseService <LogEntity, Long> {

    @Autowired
    private LogRepository logRepository;

    @Override
    protected BasicJpaRepository <LogEntity, Long> getRepository() {
        return logRepository;
    }


    @Transactional
    public void clear(Boolean success){
        jpaQueryFactory.delete(LogEntity.class).where(Clauses.of().eq(Clauses.of(LogEntity::getSuccess), success)).execute();
    }


}
